import http from '@/utils/http'

const BASE_URL = '/task/testLog'

export interface TestLogResp {
  testUser: string
  startTime: string
  endTime: string
  testHour: string
  overtimeHour: string
  registerStatus: string
  testDescription: string
  isFault: string
  faultDescription: string
  name: string
  taskId: string
  createUserString: string
  updateUserString: string
}
export interface TestLogDetailResp {
  id: string
  testUser: string
  startTime: string
  endTime: string
  testHour: string
  overtimeHour: string
  registerStatus: string
  testDescription: string
  isFault: string
  faultDescription: string
  name: string
  taskId: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface TestLogQuery {
  startTime: string
  endTime: string
  registerStatus: string
  isFault: string
  name: string
  taskId: string
  sort: Array<string>
}
export interface TestLogPageQuery extends TestLogQuery, PageQuery {}

/** @desc 查询试验工作量列表 */
export function listTestLog(query: TestLogPageQuery) {
  return http.get<PageRes<TestLogResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询试验工作量详情 */
export function getTestLog(id: string) {
  return http.get<TestLogDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增试验工作量 */
export function addTestLog(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改试验工作量 */
export function updateTestLog(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除试验工作量 */
export function deleteTestLog(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出试验工作量 */
export function exportTestLog(query: TestLogQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
